import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class Page1 extends StatefulWidget {
  @override
  _Page1State createState() => _Page1State();
}

class _Page1State extends State<Page1> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        SizedBox(
          height: 200,
          child: Swiper(
            itemBuilder: (BuildContext context, int index) {
              return images[index];
            },
            itemCount: 3,
            pagination: SwiperPagination(
                builder: DotSwiperPaginationBuilder(
              color: Colors.black54,
              activeColor: Colors.white,
            )),
            control: SwiperControl(),
            scrollDirection: Axis.horizontal,
            autoplay: true,
            onTap: (index) => print('点击了第$index个'),
          ),
        ),
      ],
    );
  }

  List<Widget> images = [
    Image.network(
      "http://via.placeholder.com/350x150",
      fit: BoxFit.fill,
    ),
    Image.network(
      "http://via.placeholder.com/350x150",
      fit: BoxFit.fill,
    ),
    Image.network(
      "http://via.placeholder.com/350x150",
      fit: BoxFit.fill,
    ),
  ];
}
